<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/template.xhtml">

        <ui:define name="title">
            <h:outputText value="#{bundle.ListOperadoraTitle}"></h:outputText>
        </ui:define>

        <ui:define name="body">

            <h:form>

                <h:panelGroup id="messagePanel" layout="block">
                    <p:growl/>
                </h:panelGroup>

                <h:panelGroup>

                    <p:dataTable id="tableOperadora" value="#{operadoraController.items}" var="item" 
                                 emptyMessage="#{bundle.ListOperadoraEmpty}" style="border:solid 1px">

                        <f:facet name="header">#{bundle.ListOperadoraTitle}</f:facet>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListOperadoraTitle_descricao}"/>
                            </f:facet>
                            <h:outputText value="#{item.descricao}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <p:commandButton actionListener="#{operadoraController.prepareCreate}" value="#{bundle.ListOperadoraCreateLink}" 
                                                 update=":formOperadoraCreate:pgOperadoraCreate" oncomplete="dialogOperadoraCreate.show()"/>
                            </f:facet>
                            <p:commandButton actionListener="#{operadoraController.prepareEdit}" value="#{bundle.ListOperadoraEditLink}"
                                             update=":formOperadoraEdit:pgOperadoraEdit" oncomplete="dialogOperadoraEdit.show()"/>
                            <p:commandButton actionListener="#{operadoraController.destroy}" 
                                             value="#{bundle.ListOperadoraDestroyLink}" ajax="false"/>
                        </p:column>
                    </p:dataTable>
                </h:panelGroup>
            </h:form>

            <h:form id="formOperadoraCreate">

                <p:dialog header="Nova Operadora" widgetVar="dialogOperadoraCreate" resizable="false" modal="true" showEffect="slide">
                    <p:panelGrid id="pgOperadoraCreate" columns="2">
                        <h:outputLabel value="#{bundle.CreateOperadoraLabel_descricao}" for="descricao" />
                        <p:inputText id="descricao" value="#{operadoraController.selected.descricao}" title="#{bundle.CreateOperadoraTitle_descricao}" required="true" requiredMessage="#{bundle.CreateOperadoraRequiredMessage_descricao}"/>
                        <p:commandButton actionListener="#{operadoraController.create}" update=":formOperadoraList:tableOperadora" value="#{bundle.CreateOperadoraSaveLink}" oncomplete="#{operadoraController.prepareCreate}" ajax="false" />
                        <p:commandButton value="Limpar" type="reset" update=":formOperadoraCreate:pgOperadoraCreate" ajax="false"/>
                    </p:panelGrid>
                </p:dialog>

            </h:form>

            <h:form id="formOperadoraEdit">

                <p:dialog header="Editar Tipo de Endereço" widgetVar="dialogOperadoraEdit" resizable="false" modal="true" showEffect="slide">
                    <p:panelGrid id="pgOperadoraEdit" columns="2">
                        <h:outputLabel value="#{bundle.CreateOperadoraLabel_descricao}" for="descricao" />
                        <p:inputText id="descricao" value="#{operadoraController.selected.descricao}" title="#{bundle.CreateOperadoraTitle_descricao}" required="true" requiredMessage="#{bundle.CreateOperadoraRequiredMessage_descricao}"/>
                        <p:commandButton actionListener="#{operadoraController.update}" update=":formOperadoraList:tableOperadora" value="#{bundle.EditOperadoraSaveLink}" oncomplete="dialogOperadoraEdit.hide()" ajax="false" />
                        <p:commandButton value="Cancelar" oncomplete="dialogOperadoraEdit.hide()" ajax="false"/>
                    </p:panelGrid>
                </p:dialog>

            </h:form>

        </ui:define>
    </ui:composition>

</html>
